23 #define foreach(x, v) for (typeof (v).begin() x=(v).begin(); x !=(v).end(); ++x)
24 #define For(i, a, b) for (int i=(a); i<(b); ++i)
25 #define D(x) cout << #x " is " << x << endl
27 const int MAXN
= 10010;
28 pair
<int, int> g
[MAXN
];
32 bool compare(const pair
<int, int> &a
, const pair
<int, int> &b
) {
33 if (a
.first
!= b
.first
) return a
.first
< b
.first
;
34 return a
.second
> b
.second
;
40 while (scanf("%lld %d", &L
, &n
) == 2) {
41 if (L
== 0 and n
== 0) break;
44 for (int i
= 0; i
< n
; ++i
) {
45 long long x
, r
; scanf("%lld %lld", &x
, &r
);
46 g
[i
].first
= max(0LL, x
- r
);
47 g
[i
].second
= min(L
, x
+ r
);
48 places
[P
++] = g
[i
].first
;
49 places
[P
++] = g
[i
].second
;
52 sort(places
, places
+ P
);
53 P
= unique(places
, places
+ P
) - places
;
55 for (int i
= 0; i
< n
; ++i
) {
56 g
[i
].first
= lower_bound(places
, places
+ P
, g
[i
].first
) - places
;
57 g
[i
].second
= lower_bound(places
, places
+ P
, g
[i
].second
) - places
;
60 //sort(g, g + n, compare);
61 // for (int i = 0; i < n; ++i) {
62 // printf("<%d, %d>\n", g[i].first, g[i].second);
65 for (int i
= 0; i
< P
; ++i
) {
68 for (int i
= 0; i
< n
; ++i
) {
69 best
[g
[i
].first
] = max(best
[g
[i
].first
], g
[i
].second
);
71 for (int i
= 1; i
< P
; ++i
) {
72 best
[i
] = max(best
[i
], best
[i
-1]);
75 // for (int i = 0; i < P; ++i) {
76 // printf("best[%d] = %d\n", i, best[i]);
86 int end
= lower_bound(places
, places
+ P
, L
) - places
;
87 while (cur
< end
and cur
< best
[cur
]) {
95 printf("%d\n", n
- ans
);